Practice Problems and Solutions 6 -- Beta Reduction of Lambda Expressions

You should do these problems on paper or mentally first, and only THEN check the solution.

For the follow problems, disambiguate by giving the fully-parenthesized term. Remember that application is left-associative, and the lambda binding takes in as much right context as possible!

6.0. x y z w

Show Solution

6.1. x (y z) (w v x)

Show Solution

6.2. λy. y x x

Show Solution

6.3. x λy. y x

Show Solution

6.4. λy. λy. f y x

Show Solution

6.5. f λy. ( x λy. y ) x

Show Solution

6.6. f λy. x λy. y x

Show Solution

For the next set of problems, give the equivalent expression with the fewest parentheses.

6.7. ( ( ( x y ) z ) w )

Show Solution

6.8. ( ( x y ) ( z w ) )

Show Solution

6.9. ( λx. ( λy. ( ( y x ) w ) ) )

Show Solution

6.10. ( ( λy. ( y ( x w ) ) ) x )

Show Solution

6.11. ( ( (λx. x) (λy. y) ) ( (λz. z) w ) )

Show Solution

For the following problems, underline all beta-redexes.

6.12. (λx. x) (λy. y) ( (λz. z) w )

Show Solution

6.13. (λx. x) ( (λy. y) (λz. z) ) w

Show Solution

6.14. (λz. λx. x ( ( λx. z x ) y ) ) ( (λz. z) x )

Show Solution

6.15. x y ( λx. z )

Show Solution

In the following problems, you must reduce the terms to normal form; there is only one redex in each step, so no choice about which redex to apply.

Except for the last few problems in this set of practice problems, where it is noted, in none of these do you have to worry about free-variable capture and changing the bound variable using alpha-conversion.

6.16. Reduce: ( ( λx. x ) ( λy. y ) ) z

Show Solution

6.17. Reduce: ( λx. x ) ( λy. y ) ( λz. z )

Show Solution

6.18. Reduce: ( λx. x y ) ( λy. y x ) ( λz. z w )

Show Solution

For the following lambda expressions, reduce to normal form, using the order (normal or applicative) as indicated. Remember the rule: in normal order, the leftmost redex is reduced, and in applicative the right-most redex is reduced. So, scan through the expression and look for the leftmost (respectively, rightmost) lambda symbol in a redex. You will see that either of these ends up with the same normal form, due to the confluence property of beta-reduction.

6.19. Reduce using normal order: ( λx. ( λy. y x ) w ) z

Show Solution

6.20. Repeat 6.19 but using applicative order.

Show Solution

6.21. Reduce using normal order: (λx. x) ((λy. y) ((λz. z) w))

Show Solution

6.22. Repeat 6.21 but using applicative order.

Show Solution

6.23. Reduce using normal order: ( λx. x y ) ( λy. y x ) x

Show Solution

6.24. Repeat 6.23 but using applicative order.

Show Solution

6.25. Reduce using normal order: ( ( ( λx. x x ) ( λy. x y ) ) w )

Show Solution

6.26. Reduce using normal order: ( ( ( λx. ( x x ) ) ( λy. ( y x ) ) ) w )

Show Solution

6.27. Reduce using normal order: ( ( ( λx. ( x w ) ) ( λy. ( v y ) ) ) ( w z ) )

Show Solution

6.28. Reduce using normal order: ( ( λx. ( x ( x w ) ) ) ( ( λy. ( y v ) ) w ) )

Show Solution

6.29. Reduce using normal order: ( λx. ( λy. ( λz. x y ) x ) ) ( λw. w x ) ( λv. y v )

Show Solution

6.30. Reduce using normal order: ( λx. ( λx. ( λy. x y ) ) ( λz. y z x ) ) w

Show Solution

6.31. Reduce using normal order: ( ( λf. ( λx. ( f ( f ( f x ) ) ) ) ) ( λz. ( w z ) ) )

Show Solution

6.32. Reduce using normal order: ( ( λf. ( λx. ( f ( f x ) ) ) ) ( λz. ( z w ) ) )

Show Solution

6.33. Reduce using normal order: ( λf. f ( λx. ( λy. y) ) ( λx. (λy.x) ) ) ( λx. (λy. x) )   (This is lam_not (true) from Lab 04.)

Show Solution

For the following two problems, "reduce" the expression until you see the pattern, and also explain the pattern in words.

6.34. (λx.x x) (λx.x x)

Show Solution

6.35. (λx.x x x) (λx.x x x)

Show Solution

6.36. ( λf. ( λx. f ( x x ) ) ( λx. f ( x x ) ) ) ( $ )   (This is called the "Y-Combinator." Assume $ is a constant -- Google "Y-Combinator" if you want to understand the joke!)

Show Solution

For the following problem, the reduction sequence involves "free variable capture"; perform the reduction as we did above, and then explain precisely what happens to change a free variable into a bound variable.

6.37. ( λf. ( λx. f(f x ) ) ) ( λz. z x )

Show Solution

For the following, reduce to normal form using normal-order reduction; avoid free variable capture by renaming: add a prime to any bound variable which needs to be renamed to avoid capturing a free variable.

6.38. ( λx. ( λy. y x ) x ) y

Show Solution

6.39. ( λx. ( λy. y x ) x ) ( λx. x y )

Show Solution

6.40. (λx.(λy.y(λy.y(λy.y x)))) y

Show Solution